/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package VO;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HELIOS
 */
@Entity
@Table(name = "area", catalog = "profesoresfund", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CArea.findAll", query = "SELECT c FROM CArea c"),
    @NamedQuery(name = "CArea.findByIdArea", query = "SELECT c FROM CArea c WHERE c.cAreaPK.idArea = :idArea"),
    @NamedQuery(name = "CArea.findByIdFacultad", query = "SELECT c FROM CArea c WHERE c.cAreaPK.idFacultad = :idFacultad"),
    @NamedQuery(name = "CArea.findByArea", query = "SELECT c FROM CArea c WHERE c.area = :area")})
public class CArea implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CAreaPK cAreaPK;
    @Basic(optional = false)
    @Column(name = "area", nullable = false, length = 60)
    private String area;
    @ManyToMany(mappedBy = "cAreaCollection")
    private Collection<CProfesor> cProfesorCollection;
    @JoinColumn(name = "idFacultad", referencedColumnName = "idFacultad", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private CFacultad cFacultad;

    public CArea() {
    }

    public CArea(CAreaPK cAreaPK) {
        this.cAreaPK = cAreaPK;
    }

    public CArea(CAreaPK cAreaPK, String area) {
        this.cAreaPK = cAreaPK;
        this.area = area;
    }

    public CArea(int idArea, int idFacultad) {
        this.cAreaPK = new CAreaPK(idArea, idFacultad);
    }

    public CAreaPK getCAreaPK() {
        return cAreaPK;
    }

    public void setCAreaPK(CAreaPK cAreaPK) {
        this.cAreaPK = cAreaPK;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    @XmlTransient
    public Collection<CProfesor> getCProfesorCollection() {
        return cProfesorCollection;
    }

    public void setCProfesorCollection(Collection<CProfesor> cProfesorCollection) {
        this.cProfesorCollection = cProfesorCollection;
    }

    public CFacultad getCFacultad() {
        return cFacultad;
    }

    public void setCFacultad(CFacultad cFacultad) {
        this.cFacultad = cFacultad;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cAreaPK != null ? cAreaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CArea)) {
            return false;
        }
        CArea other = (CArea) object;
        if ((this.cAreaPK == null && other.cAreaPK != null) || (this.cAreaPK != null && !this.cAreaPK.equals(other.cAreaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fundacionprofesores.CArea[ cAreaPK=" + cAreaPK + " ]";
    }
    
}
